﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AdaptiveDeNet.RAND;

namespace AdaptiveDeNet.Functions
{
    public class Dejong1 : Function 
    {
        private double[] o;

        public Dejong1(double[] upperBound, double[] lowerBound)
        {
            o = new double[upperBound.Length];

            for (int i = 0; i < o.Length; i++)
            {
                o[i] = StaticRand.NextDouble() * (upperBound[i] - lowerBound[i]) + lowerBound[i];
            }
        }

        public double Feval(double[] p)
        {
            double ret = 0;

            for (int i = 0; i < p.Length; i++)
            {
                ret += (p[i] - o[i]) * (p[i] - o[i]);   
            }

            return ret;
        }




    }
}
